// mircoApp/agents_dividend_tx/index.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: 0,
    list: [],
    page: 1,
    total_page: 0,
    nickname: "",
    avatar: "",
    member_id: "",
    all_amount: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getData();
  },
  getData(page = 1) {
    app._getNetWork({
      url: app.getNetAddresss("plugin.tx-agent-dividend.frontend.controllers.center.index"),
      data: {
        page
      },
      success: resdata => {
        wx.setNavigationBarColor({
          frontColor: '#ffffff',
          backgroundColor: "#F15353"
        });
        let {
          result,
          msg,
          data: { list,info}
        } = resdata.data;
        if (result !== 1) {
          return app.tips(msg);
        }
        console.log(resdata.data,"data=====",list,"list===")
        this.data.page = list.current_page;
        this.data.total_page = list.last_page;
        wx.setNavigationBarTitle({
          title: info.plugin_name,
        })
        if (page == 1) {
          this.setData({
            list: list.data
          })
        } else {
          let _list = this.data.list.concat(list.data);
          console.log(_list,"list===")
          this.setData({
            list:_list
          })
        }
        this.setData({
          nickname: info.nickname,
          all_amount: info.all_amount,
          member_id: info.member_id,
          avatar: info.avatar
        })


      }
    })


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

    if(this.data.page>=this.data.total_page){
      return;
    }
    let page = this.data.page + 1;
    this.getData(page);
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})